/**
 * ZHU framework. Copyright 2012-, all rights reserved.
 *
 * $Id: MainController.java 43 2012-09-14 02:20:26Z zhuxiaopeng $
 * $Revision: 43 $
 * $Date: 2012-09-14 10:20:26 +0800 (五, 2012-09-14) $
 * $Author: zhuxiaopeng $
 */
package daily.web;

import java.util.*;

import javax.enterprise.context.*;
import javax.inject.*;

import zhu.framework.web.jsf.*;
import daily.entity.*;

/**
 * <p>
 * </p>
 * 
 * @author $Author: zhuxiaopeng $
 * @version $Revision: 43 $ - $Date: 2012-09-14 10:20:26 +0800 (五, 2012-09-14) $
 */
@Named
@RequestScoped
public class MainController extends ConversationalController {
	public String selectMenu(final Menu menu) {
		sessionBean.setSelectedMenu(menu);
		endConversation();
		String format = "/admin/%s?faces-redirect=true";
		if (menu.getDefaultPage().contains("?")) {
			format = "/admin/%s&faces-redirect=true";
		}
		final String viewId = String.format(format, menu.getDefaultPage());
		return viewId;
	}

	/**
	 * <p>
	 * プロパティ<code>nowDate</code>の値を取得する。
	 * </p>
	 * 
	 * @return プロパティ<code>nowDate</code>の値
	 */
	public Date getNowDate() {
		return nowDate;
	}

	private final Date nowDate = new Date();

	@Inject
	private SessionBean sessionBean;
}
